function mock(app, url, data) {
  app.get(url, (request, response) => {
    response.json(data)
  })
}

const homeData = require('./src/mock/bookHome')
const shelfData = require('./src/mock/bookShelf')
const listData = require('./src/mock/bookList')
const flatListData = require('./src/mock/bookFlatList')

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  devServer: {
    before(app) {
      mock(app, '/book/home', homeData)
      mock(app, '/book/shelf', shelfData)
      mock(app, '/book/list', listData)
      mock(app, '/book/flat-list', flatListData)
    }
  },
  configureWebpack: {
    performance: {
      hints: 'warning',
      maxAssetSize: 524288,
      maxEntrypointSize: 524288
    }
  }
  // configureWebpack: config => {
  //   // 为生产环境修改配置...
  //   if (process.env.NODE_ENV === 'production') {
  //     config.mode = 'production';
  //     // 打包文件大小配置
  //     config.performance = {
  //       maxEntrypointSize: 10000000,
  //       maxAssetSize: 30000000
  //     }
  //   }
  // },
}
